load('D:\project\first\data\template.mat');
close all
dbstop if error
names = dir('D:\project\first\result\2\*.jpg');
folder = names(1).folder;
names = {names.name};
for i = 1:numel(names)
    I = imread(fullfile(folder,char(names(i))));
%     I = rgb2gray(colorImage);R
    im = imresize(I,[size(I,1),60]);
%     im = I;

    temp = im(:,:,3)+im(:,:,1)-im(:,:,2)*2;
%     level = graythresh(temp);
    level = 10/255;
    bw = imbinarize(temp,level);
%     imshow(temp,[]);
    figure
    imshowpair(im,bw,'montage')
end